package com.ahui.handler;


import cn.hutool.core.lang.Assert;

import java.util.HashMap;
import java.util.Map;

public class FileHandlerFactory {

    private FileHandlerFactory() {
    }

    private static final Map<String, FileHandler> strategyMap;

    static {
        strategyMap = new HashMap<>();
    }


    public static FileHandler getInvokeStrategy(String fileType) {
        FileHandler fileHandler = strategyMap.get(fileType);
        Assert.notNull(fileHandler, "不支持的文件类型：" + fileType);
        return fileHandler;
    }

    public static void register(String fileType, FileHandler fileHandler) {
        strategyMap.put(fileType, fileHandler);
    }
}
